package teamGiga.action;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import teamGiga.bean.MovieBean;
import teamGiga.dao.CartDao;
import teamGiga.dao.MovieDao;
import action.servlet.ActionForWard;

public class BuyVodAction extends Action{

	private String path;
	private boolean redirect;
	
	
	
	public BuyVodAction() {
		super();
	}

	public BuyVodAction(String path, boolean redirect) {
		super();
		this.path = path;
		this.redirect = redirect;
	}
	

	@Override
	public ActionForWard execute(HttpServletRequest request,
			HttpServletResponse response) {
		// TODO Auto-generated method stub
		
		List<MovieBean> list = new ArrayList<MovieBean>();
		
		String [] mno = request.getParameterValues("mno");
		
		System.out.println(mno.length);
		
		for(int i=0;i<mno.length;i++){
			System.out.println(mno[i]);
			try {
				list.add((MovieBean) CartDao.selectInfoMovie(Integer.parseInt(mno[i])));
			} catch (NumberFormatException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} 
			
			request.setAttribute("list", list);
		}
		
		
		return new ActionForWard(path,redirect);
	}
	
	

}
